package com.sqly.doc.menu.zyy;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ihidea.multilinechooselib.MultiLineChooseLayout;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sqly.doc.R;
import com.sqly.doc.base.MyBaseActivity;
import com.sqly.doc.menu.camera.CameraChoose;
import com.sqly.doc.pojo.JuMin;
import com.sqly.doc.pojo.RetMsg;
import com.sqly.doc.pojo.Selected;
import com.sqly.doc.pojo.Zytzbs;
import com.sqly.doc.user.choose_user;
import com.sqly.doc.util.BinderPojo;
import com.sqly.doc.util.BinderUtil;
import com.sqly.doc.util.CreateBitmap;
import com.sqly.doc.util.DateConvert;
import com.sqly.doc.util.HttpUrl;
import com.sqly.doc.util.MyToastUtil;
import com.sqly.doc.util.NetWorkUtils;
import com.sqly.doc.util.SharedPreferencesUtils;
import com.sqly.doc.util.SweetAlertDialogUtil;
import com.sqly.doc.util.Url;
import com.sqly.doc.util.UserClient;
import com.sqly.doc.util.WriteActivity;
import com.sqly.doc.view.CustomDatePicker;
import com.sqly.doc.view.StringUtils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import cz.msebera.android.httpclient.Header;

//import cn.pedant.SweetAlert.SweetAlertDialog;


/**
 * Created by Administrator on 2017/11/22 0022.
 */

public class zyy_jkglfw extends MyBaseActivity {

    //标题
    TextView title, uname;
    LinearLayout back;
    Context con = zyy_jkglfw.this;
    private CustomDatePicker customDatePicker;

    @BinderPojo(value = R.id.SFRQ, name = "SFRQ", pojoProperty = true)
    private TextView SFRQ;

    @BinderPojo(value = R.id.XINGMING, name = "XINGMING", pojoProperty = true)
    private TextView XINGMING;

    @BinderPojo(value = R.id.ZYBJZDQT, name = "ZYBJZDQT", pojoProperty = true)
    private TextView ZYBJZDQT;


    RadioGroup ZY1,ZY2,ZY3,ZY4,ZY5,ZY6,ZY7,ZY8,ZY9,ZY10,ZY11;
    RadioGroup ZY12,ZY13,ZY14,ZY15,ZY16,ZY17,ZY18,ZY19,ZY20,ZY21;
    RadioGroup ZY22,ZY23,ZY24,ZY25,ZY26,ZY27,ZY28,ZY29,ZY30,ZY31;
    RadioGroup ZY32,ZY33;

    RadioGroup QXZ,YANGXZ,YINXZ,TSZ,SRZ,XYZ,QYZ,TBZ,PHZ;

    MultiLineChooseLayout ZYBJZD;//中医保健指导
    private List<String> mqzzdata = new ArrayList<>();


    Zytzbs obj;
    boolean isadd=false;//是否是新添加
    String url="",JKDAH="";
    ImageView sfysqm, brqm, xcqm;
    String sfysqmpic = "", brqmpic = "",xcqmpic ="";
    List<Selected> slist = new ArrayList<>();
    JuMin j;

    ImageView xcpaizhao;
    TextView pz_record_id,jmqm_record_id, ysqm_record_id;
    boolean pzChange = false;

    @Override
    protected void initUI() {
        setContentView(R.layout.zyy_jkglfw);
        BinderUtil.exeFindById(zyy_jkglfw.this);
        if (NetWorkUtils.isNetworkConnected(con)) {
            if (getIntent().getStringExtra("type").equals("edit")) {
                obj = (Zytzbs) getIntent().getExtras().getSerializable("b");
                init(obj);
                if(!StringUtils.isEmpty(obj.getImg())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg(),brqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg()),brqm);
                }
                if(!StringUtils.isEmpty(obj.getImg1())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg1(),sfysqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg1()),sfysqm);
                }
                if(!StringUtils.isEmpty(obj.getImg2())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg2(),xcqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg2()),xcqm);
                }
            }else {
                obj = new Zytzbs();
                init(obj);
            }

        }
    }

    private void init(final Zytzbs obj){
        //运行时生成activity中所有控件的findViewById方法
        //BinderUtil.exeFindById(fjhdycrhsf.this);
        BinderUtil.initData(zyy_jkglfw.this, obj);
        //医生签名
        sfysqm = (ImageView) findViewById(R.id.sfysqm);
        if (obj != null && !StringUtils.isEmpty(obj.getSfysqm())) {
            sfysqmpic = obj.getSfysqm();
            sfysqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + sfysqmpic + ".jpg"));
        }
        sfysqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "lnrZygl")
                        .putExtra("imageType", "img1")
                        .putExtra("class", "zyy_jkglfw.class"), 8);
            }
        });
        //本人签名
        brqm = (ImageView) findViewById(R.id.brqm);
        if (obj != null && !StringUtils.isEmpty(obj.getBrqm())) {
            brqmpic = obj.getBrqm();
            brqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + brqmpic + ".jpg"));
        }
        brqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "lnrZygl")
                        .putExtra("imageType", "img")
                        .putExtra("class", "zyy_jkglfw.class"), 9);
            }
        });
        xcqm = (ImageView) findViewById(R.id.xcqm);
        if (obj != null && !StringUtils.isEmpty(obj.getXcqm())) {
            xcqmpic = obj.getXcqm();
            xcqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + xcqmpic + ".jpg"));
        }
        xcqm.setOnClickListener(new CustomerListener());
        //现场拍照
        xcpaizhao = (ImageView) findViewById(R.id.xcpaizhao);
        xcpaizhao.setOnClickListener(new CustomerListener());
        //现场拍照照片id
        pz_record_id = (TextView) findViewById(R.id.pz_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg2())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg2().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                pz_record_id.setText(img2Arr[1]);
            }
        }
        jmqm_record_id= (TextView) findViewById(R.id.jmqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg())) {
            String[] img2Arr =obj.getImg().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                jmqm_record_id.setText(img2Arr[1]);
            }
        }
        ysqm_record_id= (TextView) findViewById(R.id.ysqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg1())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg1().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                ysqm_record_id.setText(img2Arr[1]);
            }
        }

        //姓名
        XINGMING = (TextView) findViewById(R.id.XINGMING);
        if (obj != null && !StringUtils.isEmpty(obj.getXINGMING())) {
            XINGMING.setText(obj.getXINGMING());
        }
        XINGMING.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!NetWorkUtils.isNetworkConnected(con)) {
                    MyToastUtil.ShowToast(con, "联网失败！");
                }else {
                    Bundle bundle = getIntent().getExtras();
                    if (null != bundle.getString("type") && "add".equals(bundle.getString("type"))) {
                        startActivityForResult(new Intent(con, choose_user.class).putExtra("cname", "zyy_jkglfw.class"), 1);
                    }
                }

            }
        });
        //填表日期
        SFRQ = (TextView) findViewById(R.id.SFRQ);
        if(obj != null && !StringUtils.isEmpty(obj.getSFRQ())){
            SFRQ.setText(DateConvert.dateToString(DateConvert.toDate(obj.getSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        SFRQ.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        SFRQ.setText(time.split(" ")[0]);
                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        initRadioButton();
        initMultiLineChooseLayout();

        back = (LinearLayout) findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(pzChange){
                   SweetAlertDialogUtil.WarningDialogHaveCancelAndConfirm(con,"你确认不保存数据更新吗？","现场拍照已经采集，请注意点击“保存”","确定", "返回");
                }else {
                    finish();
                }
            }
        });
        title = (TextView) findViewById(R.id.title);
        uname = (TextView) findViewById(R.id.uname);
        title.setText("老年人中医药健康管理服务记录");
        uname.setText("保存");
        uname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean validate = BinderUtil.copyDataToView(zyy_jkglfw.this, obj);
                if(!validate){

                }else if(null == XINGMING.getText().toString() || "".equals(XINGMING.getText().toString())){
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "姓名不能为空");
                }else if(null == SFRQ.getText().toString() || "".equals(SFRQ.getText().toString())) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "填表日期不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "ysqm", "0").toString()) && ysqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "随访医生签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "jmqm", "0").toString()) && jmqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "家属或本人签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "xcpz", "0").toString()) && pz_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "现场拍照不能为空");
                } else if (NetWorkUtils.isNetworkConnected(con)) {  ///网络连接
                    RequestParams ps = BinderUtil.generateRequestParamsByView(zyy_jkglfw.this);
                    //RequestParams ps = new RequestParams();
                    if (isadd) {
                        ps.add("entity.JKDAH", JKDAH);
                        url = HttpUrl.SaveZytzbs;
                    } else {
                        ps.add("entity.SFJLH", obj.getSFJLH());
                        ps.add("entity.JKDAH", obj.getJKDAH());
                        url = HttpUrl.EditZytzbs;
                    }
                    ps.add("entity.ZY1", obj.getZY1());
                    ps.add("entity.ZY2", obj.getZY2());
                    ps.add("entity.ZY3", obj.getZY3());
                    ps.add("entity.ZY4", obj.getZY4());
                    ps.add("entity.ZY5", obj.getZY5());
                    ps.add("entity.ZY6", obj.getZY6());
                    ps.add("entity.ZY7", obj.getZY7());
                    ps.add("entity.ZY8", obj.getZY8());
                    ps.add("entity.ZY9", obj.getZY9());
                    ps.add("entity.ZY10", obj.getZY10());
                    ps.add("entity.ZY11", obj.getZY11());
                    ps.add("entity.ZY12", obj.getZY12());
                    ps.add("entity.ZY13", obj.getZY13());
                    ps.add("entity.ZY14", obj.getZY14());
                    ps.add("entity.ZY15", obj.getZY15());
                    ps.add("entity.ZY16", obj.getZY16());
                    ps.add("entity.ZY17", obj.getZY17());
                    ps.add("entity.ZY18", obj.getZY18());
                    ps.add("entity.ZY19", obj.getZY19());
                    ps.add("entity.ZY20", obj.getZY20());
                    ps.add("entity.ZY21", obj.getZY22());
                    ps.add("entity.ZY22", obj.getZY22());
                    ps.add("entity.ZY23", obj.getZY23());
                    ps.add("entity.ZY24", obj.getZY24());
                    ps.add("entity.ZY25", obj.getZY25());
                    ps.add("entity.ZY26", obj.getZY26());
                    ps.add("entity.ZY27", obj.getZY27());
                    ps.add("entity.ZY28", obj.getZY28());
                    ps.add("entity.ZY29", obj.getZY29());
                    ps.add("entity.ZY30", obj.getZY30());
                    ps.add("entity.ZY31", obj.getZY31());
                    ps.add("entity.ZY32", obj.getZY32());
                    ps.add("entity.ZY33", obj.getZY33());

                    //中医保健指导
                    ArrayList<Integer> jwslist = ZYBJZD.getAllItemSelectedIndex();
                    String jwss = "";
                    for (int i = 0; i < jwslist.size(); i++) {
                        //System.out.println("jwslist.get(i)========="+jwslist.get(i));
                        if (i == 0)
                            jwss = (Integer.parseInt(jwslist.get(i)+"")+1) + "";
                        else
                            jwss = jwss + "," + (Integer.parseInt(jwslist.get(i)+"")+1);
                    }
                    ps.add("entity.ZYBJZD", jwss);
                    ps.add("entity.XINGMING", obj.getXINGMING());
//                    ps.add("entity.SFRQ", obj.getSFRQ());
                    ps.add("entity.CARDNUM", obj.getCARDNUM());
                    ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
                    ps.add("type", "2");

                    ps.add("pz_record_id", pz_record_id.getText().toString());
                    ps.add("jmqm_record_id", jmqm_record_id.getText().toString());
                    ps.add("ysqm_record_id", jmqm_record_id.getText().toString());
                    ps.add("entity.UPDATETIME", obj.getUPDATETIME());
                    //zyy_jkglfw.super.ImageUploadOperate(sfysqmpic, brqmpic, ps);
                    UserClient.get(url, ps, new AsyncHttpResponseHandler() {
                        @Override
                        public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                            String content = new String(response);
                            RetMsg ret = JSON.parseObject(content, RetMsg.class);
                            if (ret.getCode().equals("200")) {
                                MyToastUtil.ShowToast(con, "成功");
                            }else{
                                MyToastUtil.ShowToast(con, ret.getInfo());
                            }
                            finish();
                        }

                        @Override
                        public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                            MyToastUtil.ShowToast(con, "失败");
                        }
                    });
                } else {
                    MyToastUtil.ShowToast(con, "失败");
                }
            }
        });

    }

    /***
     * 初始化initMultiLineChooseLayout组件
     */
    private void initMultiLineChooseLayout(){
        //目前症状
        ZYBJZD = (MultiLineChooseLayout) findViewById(R.id.ZYBJZD);
        mqzzdata.add("情志调摄");
        mqzzdata.add("饮食调养");
        mqzzdata.add("起居调摄");
        mqzzdata.add("运动保健");
        mqzzdata.add("穴位保健");
        mqzzdata.add("其他");
        ZYBJZD.setList(mqzzdata);
        if (obj != null && !StringUtils.isEmpty(obj.getZYBJZD())) {
            String[] zzList = obj.getZYBJZD().split(",");

            if (Arrays.asList(zzList).contains("1"))
                ZYBJZD.setIndexItemSelected(0);
            if (Arrays.asList(zzList).contains("2"))
                ZYBJZD.setIndexItemSelected(1);
            if (Arrays.asList(zzList).contains("3"))
                ZYBJZD.setIndexItemSelected(2);
            if (Arrays.asList(zzList).contains("4"))
                ZYBJZD.setIndexItemSelected(3);
            if (Arrays.asList(zzList).contains("5"))
                ZYBJZD.setIndexItemSelected(4);
            if (Arrays.asList(zzList).contains("6"))
                ZYBJZD.setIndexItemSelected(5);
        }
    }

    private void initRadioButton(){
        //问题1
        ZY1 = findViewById(R.id.ZY1);
        if (obj != null && !StringUtils.isEmpty(obj.getZY1())) {
            switch (Integer.parseInt(obj.getZY1())) {
                case 1:
                    ZY1.check(R.id.ZY_11);
                    break;
                case 2:
                    ZY1.check(R.id.ZY_12);
                    break;
                case 3:
                    ZY1.check(R.id.ZY_13);
                    break;
                case 4:
                    ZY1.check(R.id.ZY_14);
                    break;
                case 5:
                    ZY1.check(R.id.ZY_15);
                    break;
            }
        }else{
            obj.setZY1("1");
        }
        ZY1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_11) {
                    obj.setZY1("1");
                } else if (checkedId == R.id.ZY_12) {
                    obj.setZY1("2");
                }else if (checkedId == R.id.ZY_13) {
                    obj.setZY1("3");
                }else if (checkedId == R.id.ZY_14) {
                    obj.setZY1("4");
                }else{
                    obj.setZY1("5");
                }
            }
        });

        //问题2
        ZY2 = findViewById(R.id.ZY2);
        if (obj != null && !StringUtils.isEmpty(obj.getZY2())) {
            switch (Integer.parseInt(obj.getZY2())) {
                case 1:
                    ZY2.check(R.id.ZY_21);
                    break;
                case 2:
                    ZY2.check(R.id.ZY_22);
                    break;
                case 3:
                    ZY2.check(R.id.ZY_23);
                    break;
                case 4:
                    ZY2.check(R.id.ZY_24);
                    break;
                case 5:
                    ZY2.check(R.id.ZY_25);
                    break;
            }
        }else{
            obj.setZY2("1");
        }
        ZY2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_21) {
                    obj.setZY2("1");
                } else if (checkedId == R.id.ZY_22) {
                    obj.setZY2("2");
                }else if (checkedId == R.id.ZY_23) {
                    obj.setZY2("3");
                }else if (checkedId == R.id.ZY_24) {
                    obj.setZY2("4");
                }else{
                    obj.setZY2("5");
                }
            }
        });
        //问题3
        ZY3 = findViewById(R.id.ZY3);
        if (obj != null && !StringUtils.isEmpty(obj.getZY3())) {
            switch (Integer.parseInt(obj.getZY3())) {
                case 1:
                    ZY3.check(R.id.ZY_31);
                    break;
                case 2:
                    ZY3.check(R.id.ZY_32);
                    break;
                case 3:
                    ZY3.check(R.id.ZY_33);
                    break;
                case 4:
                    ZY3.check(R.id.ZY_34);
                    break;
                case 5:
                    ZY3.check(R.id.ZY_35);
                    break;
            }
        }else{
            obj.setZY3("1");
        }
        ZY3.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_31) {
                    obj.setZY3("1");
                } else if (checkedId == R.id.ZY_32) {
                    obj.setZY3("2");
                }else if (checkedId == R.id.ZY_33) {
                    obj.setZY3("3");
                }else if (checkedId == R.id.ZY_34) {
                    obj.setZY3("4");
                }else{
                    obj.setZY3("5");
                }
            }
        });
        //问题4
        ZY4 = findViewById(R.id.ZY4);
        if (obj != null && !StringUtils.isEmpty(obj.getZY4())) {
            switch (Integer.parseInt(obj.getZY4())) {
                case 1:
                    ZY4.check(R.id.ZY_41);
                    break;
                case 2:
                    ZY4.check(R.id.ZY_42);
                    break;
                case 3:
                    ZY4.check(R.id.ZY_43);
                    break;
                case 4:
                    ZY4.check(R.id.ZY_44);
                    break;
                case 5:
                    ZY4.check(R.id.ZY_45);
                    break;
            }
        }else{
            obj.setZY4("1");
        }
        ZY4.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_41) {
                    obj.setZY4("1");
                } else if (checkedId == R.id.ZY_42) {
                    obj.setZY4("2");
                }else if (checkedId == R.id.ZY_43) {
                    obj.setZY4("3");
                }else if (checkedId == R.id.ZY_44) {
                    obj.setZY4("4");
                }else{
                    obj.setZY4("5");
                }
            }
        });

        //问题5
        ZY5 = findViewById(R.id.ZY5);
        if (obj != null && !StringUtils.isEmpty(obj.getZY5())) {
            switch (Integer.parseInt(obj.getZY5())) {
                case 1:
                    ZY5.check(R.id.ZY_51);
                    break;
                case 2:
                    ZY5.check(R.id.ZY_52);
                    break;
                case 3:
                    ZY5.check(R.id.ZY_53);
                    break;
                case 4:
                    ZY5.check(R.id.ZY_54);
                    break;
                case 5:
                    ZY5.check(R.id.ZY_55);
                    break;
            }
        }else{
            obj.setZY5("1");
        }
        ZY5.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_51) {
                    obj.setZY5("1");
                } else if (checkedId == R.id.ZY_52) {
                    obj.setZY5("2");
                }else if (checkedId == R.id.ZY_53) {
                    obj.setZY5("3");
                }else if (checkedId == R.id.ZY_54) {
                    obj.setZY5("4");
                }else{
                    obj.setZY5("5");
                }
            }
        });

        //问题6
        ZY6 = findViewById(R.id.ZY6);
        if (obj != null && !StringUtils.isEmpty(obj.getZY6())) {
            switch (Integer.parseInt(obj.getZY6())) {
                case 1:
                    ZY6.check(R.id.ZY_61);
                    break;
                case 2:
                    ZY6.check(R.id.ZY_62);
                    break;
                case 3:
                    ZY6.check(R.id.ZY_63);
                    break;
                case 4:
                    ZY6.check(R.id.ZY_64);
                    break;
                case 5:
                    ZY6.check(R.id.ZY_65);
                    break;
            }
        }else{
            obj.setZY6("1");
        }
        ZY6.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_61) {
                    obj.setZY6("1");
                } else if (checkedId == R.id.ZY_62) {
                    obj.setZY6("2");
                }else if (checkedId == R.id.ZY_63) {
                    obj.setZY6("3");
                }else if (checkedId == R.id.ZY_64) {
                    obj.setZY6("4");
                }else{
                    obj.setZY6("5");
                }
            }
        });
        //问题7
        ZY7 = findViewById(R.id.ZY7);
        if (obj != null && !StringUtils.isEmpty(obj.getZY7())) {
            switch (Integer.parseInt(obj.getZY7())) {
                case 1:
                    ZY7.check(R.id.ZY_71);
                    break;
                case 2:
                    ZY7.check(R.id.ZY_72);
                    break;
                case 3:
                    ZY7.check(R.id.ZY_73);
                    break;
                case 4:
                    ZY7.check(R.id.ZY_74);
                    break;
                case 5:
                    ZY7.check(R.id.ZY_75);
                    break;
            }
        }else{
            obj.setZY7("1");
        }
        ZY7.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_71) {
                    obj.setZY7("1");
                } else if (checkedId == R.id.ZY_72) {
                    obj.setZY7("2");
                }else if (checkedId == R.id.ZY_73) {
                    obj.setZY7("3");
                }else if (checkedId == R.id.ZY_74) {
                    obj.setZY7("4");
                }else{
                    obj.setZY7("5");
                }
            }
        });
        //问题8
        ZY8 = findViewById(R.id.ZY8);
        if (obj != null && !StringUtils.isEmpty(obj.getZY8())) {
            switch (Integer.parseInt(obj.getZY8())) {
                case 1:
                    ZY8.check(R.id.ZY_81);
                    break;
                case 2:
                    ZY8.check(R.id.ZY_82);
                    break;
                case 3:
                    ZY8.check(R.id.ZY_83);
                    break;
                case 4:
                    ZY8.check(R.id.ZY_84);
                    break;
                case 5:
                    ZY8.check(R.id.ZY_85);
                    break;
            }
        }else{
            obj.setZY8("1");
        }
        ZY8.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_81) {
                    obj.setZY8("1");
                } else if (checkedId == R.id.ZY_82) {
                    obj.setZY8("2");
                }else if (checkedId == R.id.ZY_83) {
                    obj.setZY8("3");
                }else if (checkedId == R.id.ZY_84) {
                    obj.setZY8("4");
                }else{
                    obj.setZY8("5");
                }
            }
        });

        //问题9
        ZY9 = findViewById(R.id.ZY9);
        RadioButton ZY_91 = findViewById(R.id.ZY_91);
        RadioButton ZY_92 = findViewById(R.id.ZY_92);
        RadioButton ZY_93 = findViewById(R.id.ZY_93);
        RadioButton ZY_94 = findViewById(R.id.ZY_94);
        RadioButton ZY_95 = findViewById(R.id.ZY_95);

        ZY_91.setText( "BMI＜24");
        ZY_92.setText("24≤BMI＜25");
        ZY_93.setText("25≤BMI＜26");
        ZY_94.setText("26≤BMI＜28" );
        ZY_95.setText("BMI≥28");
        if (obj != null && !StringUtils.isEmpty(obj.getZY9())) {
            switch (Integer.parseInt(obj.getZY9())) {
                case 1:
                    ZY9.check(R.id.ZY_91);
                    break;
                case 2:
                    ZY9.check(R.id.ZY_92);
                    break;
                case 3:
                    ZY9.check(R.id.ZY_93);
                    break;
                case 4:
                    ZY9.check(R.id.ZY_94);
                    break;
                case 5:
                    ZY9.check(R.id.ZY_95);
                    break;
            }
        } else{
            obj.setZY9("1");
        }
        ZY9.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_91) {
                    obj.setZY9("1");
                } else if (checkedId == R.id.ZY_92) {
                    obj.setZY9("2");
                }else if (checkedId == R.id.ZY_93) {
                    obj.setZY9("3");
                }else if (checkedId == R.id.ZY_94) {
                    obj.setZY9("4");
                }else{
                    obj.setZY9("5");
                }
            }
        });

        //问题10
        ZY10 = findViewById(R.id.ZY10);
        if (obj != null && !StringUtils.isEmpty(obj.getZY10())) {
            switch (Integer.parseInt(obj.getZY10())) {
                case 1:
                    ZY10.check(R.id.ZY_101);
                    break;
                case 2:
                    ZY10.check(R.id.ZY_102);
                    break;
                case 3:
                    ZY10.check(R.id.ZY_103);
                    break;
                case 4:
                    ZY10.check(R.id.ZY_104);
                    break;
                case 5:
                    ZY10.check(R.id.ZY_105);
                    break;
            }
        } else{
            obj.setZY10("1");
        }
        ZY10.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_101) {
                    obj.setZY10("1");
                } else if (checkedId == R.id.ZY_102) {
                    obj.setZY10("2");
                }else if (checkedId == R.id.ZY_103) {
                    obj.setZY10("3");
                }else if (checkedId == R.id.ZY_104) {
                    obj.setZY10("4");
                }else{
                    obj.setZY10("5");
                }
            }
        });
        //问题11
        ZY11 = findViewById(R.id.ZY11);
        if (obj != null && !StringUtils.isEmpty(obj.getZY11())) {
            switch (Integer.parseInt(obj.getZY11())) {
                case 1:
                    ZY11.check(R.id.ZY_111);
                    break;
                case 2:
                    ZY11.check(R.id.ZY_112);
                    break;
                case 3:
                    ZY11.check(R.id.ZY_113);
                    break;
                case 4:
                    ZY11.check(R.id.ZY_114);
                    break;
                case 5:
                    ZY11.check(R.id.ZY_115);
                    break;
            }
        } else{
            obj.setZY11("1");
        }
        ZY11.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_111) {
                    obj.setZY11("1");
                } else if (checkedId == R.id.ZY_112) {
                    obj.setZY11("2");
                }else if (checkedId == R.id.ZY_113) {
                    obj.setZY11("3");
                }else if (checkedId == R.id.ZY_114) {
                    obj.setZY11("4");
                }else{
                    obj.setZY11("5");
                }
            }
        });
        //问题12
        ZY12 = findViewById(R.id.ZY12);
        if (obj != null && !StringUtils.isEmpty(obj.getZY12())) {
            switch (Integer.parseInt(obj.getZY12())) {
                case 1:
                    ZY12.check(R.id.ZY_121);
                    break;
                case 2:
                    ZY12.check(R.id.ZY_122);
                    break;
                case 3:
                    ZY12.check(R.id.ZY_123);
                    break;
                case 4:
                    ZY12.check(R.id.ZY_124);
                    break;
                case 5:
                    ZY12.check(R.id.ZY_125);
                    break;
            }
        } else{
            obj.setZY12("1");
        }
        ZY12.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_121) {
                    obj.setZY12("1");
                } else if (checkedId == R.id.ZY_122) {
                    obj.setZY12("2");
                }else if (checkedId == R.id.ZY_123) {
                    obj.setZY12("3");
                }else if (checkedId == R.id.ZY_124) {
                    obj.setZY12("4");
                }else{
                    obj.setZY14("5");
                }
            }
        });
        //问题13
        ZY13 = findViewById(R.id.ZY13);
        if (obj != null && !StringUtils.isEmpty(obj.getZY13())) {
            switch (Integer.parseInt(obj.getZY13())) {
                case 1:
                    ZY13.check(R.id.ZY_131);
                    break;
                case 2:
                    ZY13.check(R.id.ZY_132);
                    break;
                case 3:
                    ZY13.check(R.id.ZY_133);
                    break;
                case 4:
                    ZY13.check(R.id.ZY_134);
                    break;
                case 5:
                    ZY13.check(R.id.ZY_135);
                    break;
            }
        } else{
            obj.setZY13("1");
        }
        ZY13.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_131) {
                    obj.setZY13("1");
                } else if (checkedId == R.id.ZY_132) {
                    obj.setZY13("2");
                }else if (checkedId == R.id.ZY_133) {
                    obj.setZY13("3");
                }else if (checkedId == R.id.ZY_134) {
                    obj.setZY13("4");
                }else{
                    obj.setZY13("5");
                }
            }
        });
        //问题14
        ZY14 = findViewById(R.id.ZY14);
        ZY14 = findViewById(R.id.ZY14);
        RadioButton ZY_141 = findViewById(R.id.ZY_141);
        RadioButton ZY_142 = findViewById(R.id.ZY_142);
        RadioButton ZY_143 = findViewById(R.id.ZY_143);
        RadioButton ZY_144 = findViewById(R.id.ZY_144);
        RadioButton ZY_145 = findViewById(R.id.ZY_145);

        ZY_141.setText( "一年＜2次");
        ZY_142.setText("一年感冒2-4次");
        ZY_143.setText("一年感冒5-6次");
        ZY_144.setText("一年8次以上" );
        ZY_145.setText("几乎每月都感冒");
        if (obj != null && !StringUtils.isEmpty(obj.getZY14())) {
            switch (Integer.parseInt(obj.getZY14())) {
                case 1:
                    ZY14.check(R.id.ZY_141);
                    break;
                case 2:
                    ZY14.check(R.id.ZY_142);
                    break;
                case 3:
                    ZY14.check(R.id.ZY_143);
                    break;
                case 4:
                    ZY14.check(R.id.ZY_144);
                    break;
                case 5:
                    ZY14.check(R.id.ZY_145);
                    break;
            }
        }else{
            obj.setZY14("1");
        }
        ZY14.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_141) {
                    obj.setZY14("1");
                } else if (checkedId == R.id.ZY_142) {
                    obj.setZY14("2");
                }else if (checkedId == R.id.ZY_143) {
                    obj.setZY14("3");
                }else if (checkedId == R.id.ZY_144) {
                    obj.setZY14("4");
                }else{
                    obj.setZY14("5");
                }
            }
        });
        //问题15
        ZY15 = findViewById(R.id.ZY15);
        if (obj != null && !StringUtils.isEmpty(obj.getZY15())) {
            switch (Integer.parseInt(obj.getZY15())) {
                case 1:
                    ZY15.check(R.id.ZY_151);
                    break;
                case 2:
                    ZY15.check(R.id.ZY_152);
                    break;
                case 3:
                    ZY15.check(R.id.ZY_153);
                    break;
                case 4:
                    ZY15.check(R.id.ZY_154);
                    break;
                case 5:
                    ZY15.check(R.id.ZY_155);
                    break;
            }
        }else{
            obj.setZY15("1");
        }
        ZY15.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_151) {
                    obj.setZY15("1");
                } else if (checkedId == R.id.ZY_152) {
                    obj.setZY15("2");
                }else if (checkedId == R.id.ZY_153) {
                    obj.setZY15("3");
                }else if (checkedId == R.id.ZY_154) {
                    obj.setZY15("4");
                }else{
                    obj.setZY15("5");
                }
            }
        });
        //问题16
        ZY16 = findViewById(R.id.ZY16);
        if (obj != null && !StringUtils.isEmpty(obj.getZY16())) {
            switch (Integer.parseInt(obj.getZY16())) {
                case 1:
                    ZY16.check(R.id.ZY_161);
                    break;
                case 2:
                    ZY16.check(R.id.ZY_162);
                    break;
                case 3:
                    ZY16.check(R.id.ZY_163);
                    break;
                case 4:
                    ZY16.check(R.id.ZY_164);
                    break;
                case 5:
                    ZY16.check(R.id.ZY_165);
                    break;
            }
        }else{
            obj.setZY16("1");
        }
        ZY16.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_161) {
                    obj.setZY16("1");
                } else if (checkedId == R.id.ZY_162) {
                    obj.setZY16("2");
                }else if (checkedId == R.id.ZY_163) {
                    obj.setZY16("3");
                }else if (checkedId == R.id.ZY_164) {
                    obj.setZY16("4");
                }else{
                    obj.setZY16("5");
                }
            }
        });
        //问题17
        ZY17 = findViewById(R.id.ZY17);
        RadioButton ZY_171 = findViewById(R.id.ZY_171);
        RadioButton ZY_172 = findViewById(R.id.ZY_172);
        RadioButton ZY_173 = findViewById(R.id.ZY_173);
        RadioButton ZY_174 = findViewById(R.id.ZY_174);
        RadioButton ZY_175 = findViewById(R.id.ZY_175);

        ZY_171.setText( "从来没有");
        ZY_172.setText("一年 1、2次");
        ZY_173.setText("一年 3、4次");
        ZY_174.setText("一年 5、6次" );
        ZY_175.setText("每次遇到上述原因都过敏");
        if (obj != null && !StringUtils.isEmpty(obj.getZY17())) {
            switch (Integer.parseInt(obj.getZY17())) {
                case 1:
                    ZY17.check(R.id.ZY_171);
                    break;
                case 2:
                    ZY17.check(R.id.ZY_172);
                    break;
                case 3:
                    ZY17.check(R.id.ZY_173);
                    break;
                case 4:
                    ZY17.check(R.id.ZY_174);
                    break;
                case 5:
                    ZY17.check(R.id.ZY_175);
                    break;
            }
        }else{
            obj.setZY17("1");
        }
        ZY17.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_171) {
                    obj.setZY17("1");
                } else if (checkedId == R.id.ZY_172) {
                    obj.setZY17("2");
                }else if (checkedId == R.id.ZY_173) {
                    obj.setZY17("3");
                }else if (checkedId == R.id.ZY_174) {
                    obj.setZY17("4");
                }else{
                    obj.setZY17("5");
                }
            }
        });
        //问题18
        ZY18 = findViewById(R.id.ZY18);
        if (obj != null && !StringUtils.isEmpty(obj.getZY18())) {
            switch (Integer.parseInt(obj.getZY18())) {
                case 1:
                    ZY18.check(R.id.ZY_181);
                    break;
                case 2:
                    ZY18.check(R.id.ZY_182);
                    break;
                case 3:
                    ZY18.check(R.id.ZY_183);
                    break;
                case 4:
                    ZY18.check(R.id.ZY_184);
                    break;
                case 5:
                    ZY18.check(R.id.ZY_185);
                    break;
            }
        }else{
            obj.setZY18("1");
        }
        ZY18.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_181) {
                    obj.setZY18("1");
                } else if (checkedId == R.id.ZY_182) {
                    obj.setZY18("2");
                }else if (checkedId == R.id.ZY_183) {
                    obj.setZY18("3");
                }else if (checkedId == R.id.ZY_184) {
                    obj.setZY18("4");
                }else{
                    obj.setZY18("5");
                }
            }
        });
        //问题19
        ZY19 = findViewById(R.id.ZY19);
        if (obj != null && !StringUtils.isEmpty(obj.getZY19())) {
            switch (Integer.parseInt(obj.getZY19())) {
                case 1:
                    ZY19.check(R.id.ZY_191);
                    break;
                case 2:
                    ZY19.check(R.id.ZY_192);
                    break;
                case 3:
                    ZY19.check(R.id.ZY_193);
                    break;
                case 4:
                    ZY19.check(R.id.ZY_194);
                    break;
                case 5:
                    ZY19.check(R.id.ZY_195);
                    break;
            }
        }else{
            obj.setZY19("1");
        }
        ZY19.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_191) {
                    obj.setZY19("1");
                } else if (checkedId == R.id.ZY_192) {
                    obj.setZY19("2");
                }else if (checkedId == R.id.ZY_193) {
                    obj.setZY19("3");
                }else if (checkedId == R.id.ZY_194) {
                    obj.setZY19("4");
                }else{
                    obj.setZY19("5");
                }
            }
        });
        //问题20
        ZY20 = findViewById(R.id.ZY20);
        if (obj != null && !StringUtils.isEmpty(obj.getZY20())) {
            switch (Integer.parseInt(obj.getZY20())) {
                case 1:
                    ZY20.check(R.id.ZY_201);
                    break;
                case 2:
                    ZY20.check(R.id.ZY_202);
                    break;
                case 3:
                    ZY20.check(R.id.ZY_203);
                    break;
                case 4:
                    ZY20.check(R.id.ZY_204);
                    break;
                case 5:
                    ZY20.check(R.id.ZY_205);
                    break;
            }
        }else{
            obj.setZY20("1");
        }
        ZY20.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_201) {
                    obj.setZY20("1");
                } else if (checkedId == R.id.ZY_202) {
                    obj.setZY20("2");
                }else if (checkedId == R.id.ZY_203) {
                    obj.setZY20("3");
                }else if (checkedId == R.id.ZY_204) {
                    obj.setZY20("4");
                }else{
                    obj.setZY20("5");
                }
            }
        });
        //问题21
        ZY21 = findViewById(R.id.ZY21);
        if (obj != null && !StringUtils.isEmpty(obj.getZY21())) {
            switch (Integer.parseInt(obj.getZY21())) {
                case 1:
                    ZY21.check(R.id.ZY_211);
                    break;
                case 2:
                    ZY21.check(R.id.ZY_212);
                    break;
                case 3:
                    ZY21.check(R.id.ZY_213);
                    break;
                case 4:
                    ZY21.check(R.id.ZY_214);
                    break;
                case 5:
                    ZY21.check(R.id.ZY_215);
                    break;
            }
        }else{
            obj.setZY21("1");
        }
        ZY21.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_211) {
                    obj.setZY21("1");
                } else if (checkedId == R.id.ZY_212) {
                    obj.setZY21("2");
                }else if (checkedId == R.id.ZY_213) {
                    obj.setZY21("3");
                }else if (checkedId == R.id.ZY_214) {
                    obj.setZY21("4");
                }else{
                    obj.setZY21("5");
                }
            }
        });
        //问题22
        ZY22 = findViewById(R.id.ZY22);
        if (obj != null && !StringUtils.isEmpty(obj.getZY22())) {
            switch (Integer.parseInt(obj.getZY22())) {
                case 1:
                    ZY22.check(R.id.ZY_221);
                    break;
                case 2:
                    ZY22.check(R.id.ZY_222);
                    break;
                case 3:
                    ZY22.check(R.id.ZY_223);
                    break;
                case 4:
                    ZY22.check(R.id.ZY_224);
                    break;
                case 5:
                    ZY22.check(R.id.ZY_225);
                    break;
            }
        }else{
            obj.setZY22("1");
        }
        ZY22.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_221) {
                    obj.setZY22("1");
                } else if (checkedId == R.id.ZY_222) {
                    obj.setZY22("2");
                }else if (checkedId == R.id.ZY_223) {
                    obj.setZY22("3");
                }else if (checkedId == R.id.ZY_224) {
                    obj.setZY22("4");
                }else{
                    obj.setZY22("5");
                }
            }
        });
        //问题23
        ZY23 = findViewById(R.id.ZY23);
        if (obj != null && !StringUtils.isEmpty(obj.getZY23())) {
            switch (Integer.parseInt(obj.getZY23())) {
                case 1:
                    ZY23.check(R.id.ZY_231);
                    break;
                case 2:
                    ZY23.check(R.id.ZY_232);
                    break;
                case 3:
                    ZY23.check(R.id.ZY_233);
                    break;
                case 4:
                    ZY23.check(R.id.ZY_234);
                    break;
                case 5:
                    ZY23.check(R.id.ZY_235);
                    break;
            }
        }else{
            obj.setZY23("1");
        }
        ZY23.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_231) {
                    obj.setZY23("1");
                } else if (checkedId == R.id.ZY_232) {
                    obj.setZY23("2");
                }else if (checkedId == R.id.ZY_233) {
                    obj.setZY23("3");
                }else if (checkedId == R.id.ZY_234) {
                    obj.setZY23("4");
                }else{
                    obj.setZY23("5");
                }
            }
        });
        //问题24
        ZY24 = findViewById(R.id.ZY24);
        if (obj != null && !StringUtils.isEmpty(obj.getZY24())) {
            switch (Integer.parseInt(obj.getZY24())) {
                case 1:
                    ZY24.check(R.id.ZY_241);
                    break;
                case 2:
                    ZY24.check(R.id.ZY_242);
                    break;
                case 3:
                    ZY24.check(R.id.ZY_243);
                    break;
                case 4:
                    ZY24.check(R.id.ZY_244);
                    break;
                case 5:
                    ZY24.check(R.id.ZY_245);
                    break;
            }
        }else{
            obj.setZY24("1");
        }
        ZY24.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_241) {
                    obj.setZY24("1");
                } else if (checkedId == R.id.ZY_242) {
                    obj.setZY24("2");
                }else if (checkedId == R.id.ZY_243) {
                    obj.setZY24("3");
                }else if (checkedId == R.id.ZY_244) {
                    obj.setZY24("4");
                }else{
                    obj.setZY24("5");
                }
            }
        });
        //问题25
        ZY25 = findViewById(R.id.ZY25);
        if (obj != null && !StringUtils.isEmpty(obj.getZY25())) {
            switch (Integer.parseInt(obj.getZY25())) {
                case 1:
                    ZY25.check(R.id.ZY_251);
                    break;
                case 2:
                    ZY25.check(R.id.ZY_252);
                    break;
                case 3:
                    ZY25.check(R.id.ZY_253);
                    break;
                case 4:
                    ZY25.check(R.id.ZY_254);
                    break;
                case 5:
                    ZY25.check(R.id.ZY_255);
                    break;
            }
        }else{
            obj.setZY25("1");
        }
        ZY25.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_251) {
                    obj.setZY25("1");
                } else if (checkedId == R.id.ZY_252) {
                    obj.setZY25("2");
                }else if (checkedId == R.id.ZY_253) {
                    obj.setZY25("3");
                }else if (checkedId == R.id.ZY_254) {
                    obj.setZY25("4");
                }else{
                    obj.setZY25("5");
                }
            }
        });
        //问题26
        ZY26 = findViewById(R.id.ZY26);
        if (obj != null && !StringUtils.isEmpty(obj.getZY26())) {
            switch (Integer.parseInt(obj.getZY26())) {
                case 1:
                    ZY26.check(R.id.ZY_261);
                    break;
                case 2:
                    ZY26.check(R.id.ZY_262);
                    break;
                case 3:
                    ZY26.check(R.id.ZY_263);
                    break;
                case 4:
                    ZY26.check(R.id.ZY_264);
                    break;
                case 5:
                    ZY26.check(R.id.ZY_265);
                    break;
            }
        }else{
            obj.setZY26("1");
        }
        ZY26.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_261) {
                    obj.setZY26("1");
                } else if (checkedId == R.id.ZY_262) {
                    obj.setZY26("2");
                }else if (checkedId == R.id.ZY_263) {
                    obj.setZY26("3");
                }else if (checkedId == R.id.ZY_264) {
                    obj.setZY26("4");
                }else{
                    obj.setZY26("5");
                }
            }
        });
        //问题27
        ZY27 = findViewById(R.id.ZY27);
        if (obj != null && !StringUtils.isEmpty(obj.getZY27())) {
            switch (Integer.parseInt(obj.getZY27())) {
                case 1:
                    ZY27.check(R.id.ZY_271);
                    break;
                case 2:
                    ZY27.check(R.id.ZY_272);
                    break;
                case 3:
                    ZY27.check(R.id.ZY_273);
                    break;
                case 4:
                    ZY27.check(R.id.ZY_274);
                    break;
                case 5:
                    ZY27.check(R.id.ZY_275);
                    break;
            }
        }else{
            obj.setZY27("1");
        }
        ZY27.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_271) {
                    obj.setZY27("1");
                } else if (checkedId == R.id.ZY_272) {
                    obj.setZY27("2");
                }else if (checkedId == R.id.ZY_273) {
                    obj.setZY27("3");
                }else if (checkedId == R.id.ZY_274) {
                    obj.setZY27("4");
                }else{
                    obj.setZY27("5");
                }
            }
        });
        //问题28
        ZY28 = findViewById(R.id.ZY28);
        RadioButton ZY_281 = findViewById(R.id.ZY_281);
        RadioButton ZY_282 = findViewById(R.id.ZY_282);
        RadioButton ZY_283 = findViewById(R.id.ZY_283);
        RadioButton ZY_284 = findViewById(R.id.ZY_284);
        RadioButton ZY_285 = findViewById(R.id.ZY_285);

        ZY_281.setText( "腹围<80cm，相当于2.4尺");
        ZY_282.setText("腹围 80-85cm，  2.4-2.55尺");
        ZY_283.setText("腹围 86-90cm，  2.56-2.7尺");
        ZY_284.setText("腹围 91-105cm， 2.71-3.15尺" );
        ZY_285.setText("腹围>105cm或3.15尺");
        if (obj != null && !StringUtils.isEmpty(obj.getZY28())) {
            switch (Integer.parseInt(obj.getZY28())) {
                case 1:
                    ZY28.check(R.id.ZY_281);
                    break;
                case 2:
                    ZY28.check(R.id.ZY_282);
                    break;
                case 3:
                    ZY28.check(R.id.ZY_283);
                    break;
                case 4:
                    ZY28.check(R.id.ZY_284);
                    break;
                case 5:
                    ZY28.check(R.id.ZY_285);
                    break;
            }
        }else{
            obj.setZY28("1");
        }
        ZY28.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_281) {
                    obj.setZY28("1");
                } else if (checkedId == R.id.ZY_282) {
                    obj.setZY28("2");
                }else if (checkedId == R.id.ZY_283) {
                    obj.setZY28("3");
                }else if (checkedId == R.id.ZY_284) {
                    obj.setZY28("4");
                }else{
                    obj.setZY28("5");
                }
            }
        });//问题29
        ZY29 = findViewById(R.id.ZY29);
        if (obj != null && !StringUtils.isEmpty(obj.getZY29())) {
            switch (Integer.parseInt(obj.getZY29())) {
                case 1:
                    ZY29.check(R.id.ZY_291);
                    break;
                case 2:
                    ZY29.check(R.id.ZY_292);
                    break;
                case 3:
                    ZY29.check(R.id.ZY_293);
                    break;
                case 4:
                    ZY29.check(R.id.ZY_294);
                    break;
                case 5:
                    ZY29.check(R.id.ZY_295);
                    break;
            }
        }else{
            obj.setZY29("1");
        }
        ZY29.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_291) {
                    obj.setZY29("1");
                } else if (checkedId == R.id.ZY_292) {
                    obj.setZY29("2");
                }else if (checkedId == R.id.ZY_293) {
                    obj.setZY29("3");
                }else if (checkedId == R.id.ZY_294) {
                    obj.setZY29("4");
                }else{
                    obj.setZY29("5");
                }
            }
        });
        //问题30
        ZY30 = findViewById(R.id.ZY30);
        if (obj != null && !StringUtils.isEmpty(obj.getZY30())) {
            switch (Integer.parseInt(obj.getZY30())) {
                case 1:
                    ZY30.check(R.id.ZY_301);
                    break;
                case 2:
                    ZY30.check(R.id.ZY_302);
                    break;
                case 3:
                    ZY30.check(R.id.ZY_303);
                    break;
                case 4:
                    ZY30.check(R.id.ZY_304);
                    break;
                case 5:
                    ZY30.check(R.id.ZY_305);
                    break;
            }
        }else{
            obj.setZY30("1");
        }
        ZY30.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_301) {
                    obj.setZY30("1");
                } else if (checkedId == R.id.ZY_302) {
                    obj.setZY30("2");
                }else if (checkedId == R.id.ZY_303) {
                    obj.setZY30("3");
                }else if (checkedId == R.id.ZY_304) {
                    obj.setZY30("4");
                }else{
                    obj.setZY30("5");
                }
            }
        });
        //问题31
        ZY31 = findViewById(R.id.ZY31);
        if (obj != null && !StringUtils.isEmpty(obj.getZY31())) {
            switch (Integer.parseInt(obj.getZY31())) {
                case 1:
                    ZY31.check(R.id.ZY_311);
                    break;
                case 2:
                    ZY31.check(R.id.ZY_312);
                    break;
                case 3:
                    ZY31.check(R.id.ZY_313);
                    break;
                case 4:
                    ZY31.check(R.id.ZY_314);
                    break;
                case 5:
                    ZY31.check(R.id.ZY_315);
                    break;
            }
        }else{
            obj.setZY31("1");
        }
        ZY31.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_311) {
                    obj.setZY31("1");
                } else if (checkedId == R.id.ZY_312) {
                    obj.setZY31("2");
                }else if (checkedId == R.id.ZY_313) {
                    obj.setZY31("3");
                }else if (checkedId == R.id.ZY_314) {
                    obj.setZY31("4");
                }else{
                    obj.setZY31("5");
                }
            }
        });
        //问题32
        ZY32 = findViewById(R.id.ZY32);
        if (obj != null && !StringUtils.isEmpty(obj.getZY32())) {
            switch (Integer.parseInt(obj.getZY32())) {
                case 1:
                    ZY32.check(R.id.ZY_321);
                    break;
                case 2:
                    ZY32.check(R.id.ZY_322);
                    break;
                case 3:
                    ZY32.check(R.id.ZY_323);
                    break;
                case 4:
                    ZY32.check(R.id.ZY_324);
                    break;
                case 5:
                    ZY32.check(R.id.ZY_325);
                    break;
            }
        }else{
            obj.setZY32("1");
        }
        ZY32.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_321) {
                    obj.setZY32("1");
                } else if (checkedId == R.id.ZY_322) {
                    obj.setZY32("2");
                }else if (checkedId == R.id.ZY_323) {
                    obj.setZY32("3");
                }else if (checkedId == R.id.ZY_324) {
                    obj.setZY32("4");
                }else{
                    obj.setZY32("5");
                }
            }
        });
        //问题33
        ZY33 = findViewById(R.id.ZY33);
        if (obj != null && !StringUtils.isEmpty(obj.getZY33())) {
            switch (Integer.parseInt(obj.getZY33())) {
                case 1:
                    ZY33.check(R.id.ZY_331);
                    break;
                case 2:
                    ZY33.check(R.id.ZY_332);
                    break;
                case 3:
                    ZY33.check(R.id.ZY_333);
                    break;
                case 4:
                    ZY33.check(R.id.ZY_334);
                    break;
                case 5:
                    ZY33.check(R.id.ZY_335);
                    break;
            }
        }else{
            obj.setZY33("1");
        }
        ZY33.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.ZY_331) {
                    obj.setZY33("1");
                } else if (checkedId == R.id.ZY_332) {
                    obj.setZY33("2");
                }else if (checkedId == R.id.ZY_333) {
                    obj.setZY33("3");
                }else if (checkedId == R.id.ZY_334) {
                    obj.setZY33("4");
                }else{
                    obj.setZY33("5");
                }
            }
        });
        //气虚质
        QXZ= findViewById(R.id.QXZ);
        RadioButton QXZ0 = findViewById(R.id.QXZ0);
        RadioButton QXZ1 = findViewById(R.id.QXZ1);
        RadioButton QXZ2 = findViewById(R.id.QXZ2);
        QXZ0.setClickable(false);
        QXZ1.setClickable(false);
        QXZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getQXZ())) {
            switch (obj.getQXZ()) {
                case "":
                    QXZ.check(R.id.QXZ0);
                    break;
                case "1":
                    QXZ.check(R.id.QXZ1);
                    break;
                case "2":
                    QXZ.check(R.id.QXZ2);
                    break;
            }
        }else{
            obj.setQXZ("");
        }
        //阳虚质
        YANGXZ= findViewById(R.id.YANGXZ);
        RadioButton YANGXZ0 = findViewById(R.id.YANGXZ0);
        RadioButton YANGXZ1 = findViewById(R.id.YANGXZ1);
        RadioButton YANGXZ2 = findViewById(R.id.YANGXZ2);
        YANGXZ0.setClickable(false);
        YANGXZ1.setClickable(false);
        YANGXZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getYANGXZ())) {
            switch (obj.getYANGXZ()) {
                case "":
                    YANGXZ.check(R.id.YANGXZ0);
                    break;
                case "1":
                    YANGXZ.check(R.id.YANGXZ1);
                    break;
                case "2":
                    YANGXZ.check(R.id.YANGXZ2);
                    break;
            }
        }else{
            obj.setYANGXZ("");
        }
        //阴虚质
        YINXZ= findViewById(R.id.YINXZ);
        RadioButton YINXZ0 = findViewById(R.id.YINXZ0);
        RadioButton YINXZ1 = findViewById(R.id.YINXZ1);
        RadioButton YINXZ2 = findViewById(R.id.YINXZ2);
        YINXZ0.setClickable(false);
        YINXZ1.setClickable(false);
        YINXZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getYINXZ())) {
            switch (obj.getYINXZ()) {
                case "":
                    YINXZ.check(R.id.YINXZ0);
                    break;
                case "1":
                    YINXZ.check(R.id.YINXZ1);
                    break;
                case "2":
                    YINXZ.check(R.id.YINXZ2);
                    break;
            }
        }else{
            obj.setYINXZ("");
        }
        //
        TSZ= findViewById(R.id.TSZ);
        RadioButton TSZ0 = findViewById(R.id.TSZ0);
        RadioButton TSZ1 = findViewById(R.id.TSZ1);
        RadioButton TSZ2 = findViewById(R.id.TSZ2);
        TSZ0.setClickable(false);
        TSZ1.setClickable(false);
        TSZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getTSZ())) {
            switch (obj.getTSZ()) {
                case "":
                    TSZ.check(R.id.TSZ0);
                    break;
                case "1":
                    TSZ.check(R.id.TSZ1);
                    break;
                case "2":
                    TSZ.check(R.id.TSZ2);
                    break;
            }
        }else{
            obj.setTSZ("");
        }
        //
        SRZ= findViewById(R.id.SRZ);
        RadioButton SRZ0 = findViewById(R.id.SRZ0);
        RadioButton SRZ1 = findViewById(R.id.SRZ1);
        RadioButton SRZ2 = findViewById(R.id.SRZ2);
        SRZ0.setClickable(false);
        SRZ1.setClickable(false);
        SRZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getSRZ())) {
            switch (obj.getSRZ()) {
                case "":
                    SRZ.check(R.id.SRZ0);
                    break;
                case "1":
                    SRZ.check(R.id.SRZ1);
                    break;
                case "2":
                    SRZ.check(R.id.SRZ2);
                    break;
            }
        }else{
            obj.setSRZ("");
        }
                //,,,
        //
        XYZ= findViewById(R.id.XYZ);
        RadioButton XYZ0 = findViewById(R.id.XYZ0);
        RadioButton XYZ1 = findViewById(R.id.XYZ1);
        RadioButton XYZ2 = findViewById(R.id.XYZ2);
        XYZ0.setClickable(false);
        XYZ1.setClickable(false);
        XYZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getXYZ())) {
            switch (obj.getXYZ()) {
                case "":
                    XYZ.check(R.id.XYZ0);
                    break;
                case "1":
                    XYZ.check(R.id.XYZ1);
                    break;
                case "2":
                    XYZ.check(R.id.XYZ2);
                    break;
            }
        }else{
            obj.setXYZ("");
        }
        //
        QYZ= findViewById(R.id.QYZ);
        RadioButton QYZ0 = findViewById(R.id.QYZ0);
        RadioButton QYZ1 = findViewById(R.id.QYZ1);
        RadioButton QYZ2 = findViewById(R.id.QYZ2);
        QYZ0.setClickable(false);
        QYZ1.setClickable(false);
        QYZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getQYZ())) {
            switch (obj.getQYZ()) {
                case "":
                    QYZ.check(R.id.QYZ0);
                    break;
                case "1":
                    QYZ.check(R.id.QYZ1);
                    break;
                case "2":
                    QYZ.check(R.id.QYZ2);
                    break;
            }
        }else{
            obj.setQYZ("");
        }
        //
        TBZ= findViewById(R.id.QYZ);
        RadioButton TBZ0 = findViewById(R.id.TBZ0);
        RadioButton TBZ1 = findViewById(R.id.TBZ1);
        RadioButton TBZ2 = findViewById(R.id.TBZ2);
        TBZ0.setClickable(false);
        TBZ1.setClickable(false);
        TBZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getTBZ())) {
            switch (obj.getTBZ()) {
                case "":
                    TBZ.check(R.id.TBZ0);
                    break;
                case "1":
                    TBZ.check(R.id.TBZ1);
                    break;
                case "2":
                    TBZ.check(R.id.TBZ2);
                    break;
            }
        }else{
            obj.setTBZ("");
        }
        //
        PHZ= findViewById(R.id.PHZ);
        RadioButton PHZ0 = findViewById(R.id.PHZ0);
        RadioButton PHZ1 = findViewById(R.id.PHZ1);
        RadioButton PHZ2 = findViewById(R.id.PHZ2);
        PHZ0.setClickable(false);
        PHZ1.setClickable(false);
        PHZ2.setClickable(false);
        if (obj != null && !StringUtils.isEmpty(obj.getPHZ())) {
            switch (obj.getPHZ()) {
                case "":
                    PHZ.check(R.id.PHZ0);
                    break;
                case "1":
                    PHZ.check(R.id.PHZ1);
                    break;
                case "2":
                    PHZ.check(R.id.PHZ2);
                    break;
            }
        }else{
            obj.setPHZ("");
        }

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {

        } else if (requestCode == 1) {
            j = (JuMin) data.getExtras().getSerializable("j");
            getObject();
        }else if (requestCode == 8) {
            String record_id = (String) data.getExtras().getString("record_id");
            ysqm_record_id.setText(record_id);
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            sfysqm.setImageBitmap(bb);
            sfysqmpic = CreateBitmap.saveMyBitmap(bb);
        }else if (requestCode == 9) {
            String record_id = (String) data.getExtras().getString("record_id");
            jmqm_record_id.setText(record_id);
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            brqm.setImageBitmap(bb);
            brqmpic = CreateBitmap.saveMyBitmap(bb);
        }else if(requestCode == 119){
            String img_record_id = (String) data.getExtras().getString("img_record_id");
            pz_record_id.setText(img_record_id);
            pzChange = true;
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            xcqm.setImageBitmap(bb);
        }
    }

    public void getObject() {
        RequestParams ps = new RequestParams();
        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
        ps.add("type", "2");
        ps.add("CARDNUM", j.getCARDNUM());
        UserClient.get(HttpUrl.GetZytzbsGrjbxx, ps, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                String content = new String(response);
                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                if (ret.getCode().equals("200")) {
                    JSONObject j = JSON.parseObject(ret.getRd());
                    obj = new Zytzbs();
                    init(obj);
                    obj.setJKDAH(j.getString("JKDAH"));
                    obj.setXINGMING(j.getString("XINGMING"));
                    obj.setCARDNUM(j.getString("CARDNUM"));
                    JKDAH = j.getString("JKDAH");
                    XINGMING.setText(j.getString("XINGMING"));
                    isadd = true;
                } else {
                    SweetAlertDialogUtil.ErrorDialogNoFinish(con, "错误提示", ret.getInfo(), "确定");
                }

            }
            @Override
            public void onFinish() {
                super.onFinish();
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                isadd = true;
                obj = new Zytzbs();
                init(obj);
            }
        });
    }


    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    class CustomerListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            if(obj != null && StringUtils.isEmpty(obj.getJKDAH())) {
                SweetAlertDialogUtil.WarningDialog(con, "提示", "选择居民用户后才能现场拍照");
            }else {
                Intent intent = new Intent(con, CameraChoose.class)
                        .putExtra("type", "edit")
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "lnrZygl")
                        .putExtra("class", "zyy_jkglfw.class");
                startActivityForResult(intent, 119);
            }
        }
    }
}
